﻿const useChooseResource = (initInfo, emit) => {
  // 为资源弹窗时，获取当前已选中的资源
  const getActiveResource = () => {
    const res: any = []
    if (initInfo.value.sourceList.length > 0) {
      initInfo.value.sourceList.forEach((item: any) => {
        if (!item.isFolder && item.active) {
          res.push(item)
        }
      })
    }
    emit('select', res)
  }

  // 调起资源弹窗时，获取传递过来的参数
  const getChooseConfig = v => {
    console.log(v, '弹窗选择资源')
    initInfo.value.isChooseResource = true
    initInfo.value.isMultiple = v.multiple
    initInfo.value.form.type = v.type
    initInfo.value.uploadConfig.multiple = v.multiple
    initInfo.value.uploadConfig.type = v.type
    initInfo.value.uploadConfig.isAllowChangeType = false
  }

  return {
    getActiveResource,
    getChooseConfig
  }
}
export default useChooseResource
